﻿using System;
using System.Collections;
using System.IO;
using System.Web;

namespace ASPNETVN.PORTAL.Components.Configuration.Items
{
    public class Layout
    {
        public static string[] GetLayoutList()
        {
            ArrayList ret = new ArrayList();
            string path = HttpContext.Current.Server.MapPath("~/Masters");
            if (Directory.Exists(path))
            {
                string[] files = Directory.GetFiles(path);
                foreach (string s in files)
                {
                    string filename = s.Substring(s.LastIndexOf('\\') + 1);
                    string ext = filename.Substring(filename.LastIndexOf('.') + 1);
                    if (ext.ToLower() == "master")
                    {
                        filename = filename.Remove(filename.LastIndexOf(".master", StringComparison.OrdinalIgnoreCase));
                        ret.Add(filename);
                    }
                }
            }
            return (string[]) ret.ToArray(typeof (string));
        }
    }
}